using Common.Commands;
using Common.Commands.NoteCommands;
using Core.Domain.Model;
using Sanelib.DataOperation;
using Sanelib.Dto;

namespace Core.Processors.NoteProcessors
{
	public class DeleteNoteProcessor : ICommandProcessor<DeleteNote>
	{
		private readonly IRepository<Note> _noteRepository;

		public DeleteNoteProcessor(IRepository<Note> noteRepository)
		{
			_noteRepository = noteRepository;
		}

		public dynamic Process(DeleteNote command)
 		{
			var response = new WebApiResultResponse();

			var note = _noteRepository.GetById(command.Id);

			_noteRepository.Delete(note.Id);
			response.IsSuccess = true;

			return response;
		}
	}
}
